90e122
@@ -19,11 +19,16 @@
 package org.apache.hadoop.hive.hbase;
 
 import java.io.IOException;
+import java.util.Properties;
 
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.BufferedMutator;
 import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.exec.FileSinkOperator;
+import org.apache.hadoop.hive.ql.io.HiveOutputFormat;
+import org.apache.hadoop.io.Writable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.fs.FileSystem;
@@ -37,7 +42,6 @@
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.shims.ShimLoader;
 import org.apache.hadoop.mapred.JobConf;
-import org.apache.hadoop.mapred.OutputFormat;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hadoop.mapreduce.Job;
 import org.apache.hadoop.mapreduce.JobContext;
@@ -48,28 +52,12 @@
 
 /**
  * HiveHBaseTableOutputFormat implements HiveOutputFormat for HBase tables.
- * We also need to implement the @deprecated org.apache.hadoop.mapred.OutFormat<?,?>
- * class to keep it compliant with Hive interfaces.
  */
 public class HiveHBaseTableOutputFormat extends
     TableOutputFormat<ImmutableBytesWritable> implements
-    OutputFormat<ImmutableBytesWritable, Object> {
+    HiveOutputFormat<ImmutableBytesWritable, Object> {
 
   static final Logger LOG = LoggerFactory.getLogger(HiveHBaseTableOutputFormat.class);
-  public static final String HBASE_WAL_ENABLED = "hive.hbase.wal.enabled";
-
-  /**
-   * Update the out table, and output an empty key as the key.
-   *
-   * @param jc the job configuration file
-   * @param finalOutPath the final output table name
-   * @param valueClass the value class
-   * @param isCompressed whether the content is compressed or not
-   * @param tableProperties the table info of the corresponding table
-   * @param progress progress used for status report
-   * @return the RecordWriter for the output file
-   */
-
 
   @Override
   public void checkOutputSpecs(FileSystem fs, JobConf jc) throws IOException {
@@ -99,7 +87,23 @@
public void checkOutputSpecs(FileSystem fs, JobConf jc) throws IOException {
       JobConf jobConf,
       String name,
       Progressable progressable) throws IOException {
+    return getMyRecordWriter(jobConf);
+  }
 
+  @Override
+  public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws IOException,
+  InterruptedException {
+    return new TableOutputCommitter();
+  }
+
+  @Override
+  public FileSinkOperator.RecordWriter getHiveRecordWriter(
+      JobConf jobConf, Path finalOutPath, Class<? extends Writable> valueClass, boolean isCompressed,
+      Properties tableProperties, Progressable progress) throws IOException {
+    return getMyRecordWriter(jobConf);
+  }
+
+  private MyRecordWriter getMyRecordWriter(JobConf jobConf) throws IOException {
     String hbaseTableName = jobConf.get(HBaseSerDe.HBASE_TABLE_NAME);
     jobConf.set(TableOutputFormat.OUTPUT_TABLE, hbaseTableName);
     final boolean walEnabled = HiveConf.getBoolVar(
@@ -109,14 +113,9 @@
public void checkOutputSpecs(FileSystem fs, JobConf jc) throws IOException {
     return new MyRecordWriter(table, conn, walEnabled);
   }
 
-  @Override
-  public OutputCommitter getOutputCommitter(TaskAttemptContext context) throws IOException,
-  InterruptedException {
-    return new TableOutputCommitter();
-  }
-
-
-  static private class MyRecordWriter implements org.apache.hadoop.mapred.RecordWriter<ImmutableBytesWritable, Object> {
+  private static class MyRecordWriter
+      implements org.apache.hadoop.mapred.RecordWriter<ImmutableBytesWritable, Object>,
+      org.apache.hadoop.hive.ql.exec.FileSinkOperator.RecordWriter {
     private final BufferedMutator m_table;
     private final boolean m_walEnabled;
     private final Connection m_connection;
@@ -127,8 +126,7 @@
public MyRecordWriter(BufferedMutator table, Connection connection, boolean walE
       m_connection = connection;
     }
 
-    public void close(Reporter reporter)
-      throws IOException {
+    public void close(Reporter reporter) throws IOException {
       m_table.close();
     }
 
@@ -159,5 +157,15 @@
protected void finalize() throws Throwable {
         super.finalize();
       }
     }
+
+    @Override
+    public void write(Writable w) throws IOException {
+      write(null, w);
+    }
+
+    @Override
+    public void close(boolean abort) throws IOException {
+      close(null);
+    }
   }
 }
